<template>
	<slot v-if="getUserAuthBtnList" />
</template>

<script setup lang="ts" name="auths">
import { computed,PropType } from 'vue';
import { storeToRefs } from 'pinia';
import { useUserInfo } from '/@/stores/userInfo';

// 定义父组件传过来的值
const props = defineProps({
	value: {
		type: Array as () => PropType<string[]>,
		default: () => [],
	},
});

// 定义变量内容
const stores = useUserInfo();
const { userInfos } = storeToRefs(stores);

// 获取 pinia 中的用户权限
const getUserAuthBtnList = computed(() => {
  // 确保 userInfos.value.authBtnList 和 props.value 是数组
  const authBtnList = (userInfos.value.authBtnList || []) as string[];
  const valueList = props.value as unknown as string[];

  // 使用 some 方法检查是否存在匹配项
  return valueList.some((v: string) => authBtnList.includes(v));
});
</script>
